home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 02 - 1986 / 02.11 Nov 86.sit / 02.11 Nov 86 / Basic Nov86 Issue / sources / Segment Example.BAS next >
Encoding:
BASIC Source File  |  1986-09-18  |  2.1 KB  |  86 lines  |  [TEXT/ZBAS]

  1. WINDOW OFF
  2. REM Segment Loader Example ZBasic 3.02
  3. REM ©MacTutor 1986
  4. REM by Dave Kelly
  5. DIM 31 Name$(5),Vol%(5),Type&(5),Mes$(1):REM up to 5 files can be selected.
  6. DEFSTR LONG
  7. Count%=2
  8. Message%=FINDERINFO(Count%,Name$(0),Type&(0),Vol%(0))
  9. X&=MEM(-1)
  10. WINDOW 1,"Segment Sample",(50,100)-(475,300),257
  11. IF Count%<>0 THEN GOSUB "DisplayFINDERINFO"
  12. MENU 1,0,1,"File"
  13. MENU 1,1,1,"Create Data File"
  14. MENU 1,2,1,"Quit"
  15. MENU 2,0,1,"Segments"
  16. MENU 2,1,1,"Main Segment"
  17. MENU 2,2,1,"1st Segment"
  18. MENU 2,3,1,"2nd Segment"
  19. MENU 2,4,1,"3rd Segment"
  20. MENU 2,5,1,"Check memory available and unload unused segments"
  21. ON MENU GOSUB "Menuevent"
  22. MENU ON
  23. "Loop":
  24. GOTO "Loop"
  25. "Menuevent":
  26. Menunumber=MENU(0)
  27. Menuitem=MENU(1)
  28. MENU
  29. MENU OFF
  30. ON Menunumber GOSUB "Filemenu","Segmenu"
  31. MENU ON
  32. RETURN
  33. "Filemenu":
  34. IF Menuitem=1 THEN "Openfile"
  35. IF Menuitem<>2 THEN RETURN
  36. MENU RESET
  37. END
  38. "Openfile":
  39. DEF OPEN "DATADAVE"
  40. Filename$=FILES$(0,"Create new file as ...","Segment DATA")
  41. IF Filename$="" THEN RETURN
  42. OPEN O,#1,Filename$
  43. PRINT "New file named ";Filename$;" has been created.":PRINT
  44. PRINT "Quit the program and click on ";Filename$;" to see how the"
  45. PRINT "FINDERINFO function works.  Select PRINT or OPEN from the Finder."
  46. PRINT "The FINDERINFO function will indicate what has been selected."
  47. PRINT "You may want to create multiple data files and try printing"
  48. PRINT "or opening them to see what happens."
  49. RETURN
  50. "Segmenu":
  51. ON Menuitem GOSUB "Main","Seg1","Seg2","Seg3","Memory"
  52. RETURN
  53. "Main":
  54. PRINT "This is part of the main segment"
  55. RETURN
  56. SEGMENT
  57. "Seg1"
  58. PRINT "This is part of the 1st segment"
  59. SEGMENT RETURN
  60. SEGMENT
  61. "Seg2"
  62. PRINT "This is part of the 2nd segment"
  63. SEGMENT RETURN
  64. SEGMENT
  65. "Seg3"
  66. PRINT "This is part of the 3rd segment"
  67. SEGMENT RETURN
  68. SEGMENT
  69. "Memory"
  70. X&=MEM(-1)
  71. PRINT "Memory = ";X&
  72. SEGMENT RETURN
  73. SEGMENT
  74. "DisplayFINDERINFO":
  75. CLS
  76. Mes$(0)="Data file(s) should be loaded"
  77. Mes$(1)="Data file(s) should be printed"
  78. PRINT "Message% = ";Message%;" Therefore...";Mes$(Message%)
  79. PRINT "Count%   = ";Count%; "file(s) have been passed to this application"
  80. PRINT "Filenames are:"
  81. PRINT"Name","Type","Vol"
  82. FOR C=0 TO Count%-1
  83. PRINT Name$(C),MKI$(Type&(C)),Vol%(C)
  84. NEXT C
  85. SEGMENT RETURN
  86.